package com.pb.wkflow.api.controller.assembler;

import com.pb.wkflow.api.controller.assembler.mapper.TaskHandOverDtoMapper;
import com.pb.wkflow.api.controller.request.TaskHandOverCreateRequest;
import com.pb.wkflow.api.entity.TaskHandOverEntity;
import com.pb.wkflow.core.utils.AssertUtils;

/**
 * TaskHandOverAssembler
 * @author 苗益辉
 * @date 2022/12/26 16:25
 */
public class TaskHandOverAssembler {

    private TaskHandOverAssembler () {

    }

    /**
     * 创建
     * @param request request
     * @return TaskHandOverEntity
     */
    public static TaskHandOverEntity assemblerToCreate(TaskHandOverCreateRequest request) {
        AssertUtils.notEmpty(request.getUserId(), "移交人不能为空");
        AssertUtils.notEmpty(request.getHandOverUserId(), "接交人不能为空");
        AssertUtils.notEmpty(request.getStartTime(), "移交开始时间不能为空");
        AssertUtils.notEmpty(request.getEndTime(), "移交结束时间不能为空");
        return TaskHandOverDtoMapper.INSTANCE.assemblerToCreate(request);
    }

    /**
     * assemblerToEdit
     * @param request request
     * @return TaskHandOverEntity
     */
    public static TaskHandOverEntity assemblerToEdit(TaskHandOverCreateRequest request) {
        AssertUtils.notEmpty(request.getId(), "主键不能为空");
        AssertUtils.notEmpty(request.getUserId(), "移交人不能为空");
        AssertUtils.notEmpty(request.getHandOverUserId(), "接交人不能为空");
        AssertUtils.notEmpty(request.getStartTime(), "移交开始时间不能为空");
        AssertUtils.notEmpty(request.getEndTime(), "移交结束时间不能为空");
        return TaskHandOverDtoMapper.INSTANCE.assemblerToEdit(request);
    }

    /**
     * assemblerToDelete
     * @param request request
     * @return TaskHandOverEntity
     */
    public static TaskHandOverEntity assemblerToDelete(TaskHandOverCreateRequest request) {
        AssertUtils.notEmpty(request.getId(), "主键不能为空");
        return TaskHandOverDtoMapper.INSTANCE.assemblerToDelete(request);

    }
}
